home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-04-13 | 3.3 KB | 68 lines | [TEXT/GEOL] |
- Item 1174037 13-April-89 07:57
-
- From: MUYSVASOVIC1 ER&D - J-D Muys-Vasovic
-
- To: UK0004 Bacchus & Smith, Paul Smith
- UK0016 Icon Technology UK
- BEL0076 Hermes Systems SA
- FRIEDRICH1 Friedrich, Steve
- ROLLIN1 Rollin, Keith A.
- ALGER Alger, Jeff
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: Locking recap
-
- When I recall all this thread about locking objects, it seems to me that the
- problem is more general: this concerns ANY handle on the heap, that's why I
- would like to raise the following points:
-
- 1- Yes, locking is dangerous, especially as far as error handling is concerned.
- This is not related to objects or MacApp in anyway, though. Following the same
- idea, it is possible to contest the HLock, HUnlock OS routines. They prove
- necessary however, and it has always been said that they must be used
- cautiously and sparingly (though the main reason invoked is heap
- fragmentation).
-
- 2- The counting approach seems perfect, with the possible exception that it
- uses 4 bytes more per relocatable block: the count MUST be 32 bits, or at least
- more than 16 bits! But ANY block on the heap has at least 8 bytes of overhead
- (the block header), and any relocatable block on the heap has at least 12 bytes
- of overhead (with the master pointer). That would mean a 33% increase of the
- overhead. I believe memory is cheap enough nowadays to allow that.
-
- 3- I claim that the handling of the count should have been handled by the OS in
- the first (or second) place. The _HLock and _HUnlock traps should take care of
- updating the count, possibly calling SysError or Debugger when it becomes
- negative, of course depending on either a global (like $12D which controls the
- break after _LoadSeg), or better, on a field of the current zone record.
-
- 4- This can be implemented in two ways: either store another field in the block
- header for handles, or better yet, store it together with the master pointer in
- the master pointer blocks. Why is this better? Today, a master pointer is a
- 4-byte record, with 24 bits address and 8 bits flags. Tomorrow, in a 32 bits
- OS, we will need all 32 bits for the address, and the flags will have to move
- elsewhere. The solution is to make the master pointer an 8-byte record. Not 6
- because for efficiency reasons, the address must be long-word aligned. By the
- way, this is already so under A/UX. This leaves 24 bits as a possible count
- field. Now the question is: are 24 bits (16 millions limit) enough? I don't
- know. I would say yes! I think a spy tool would be easy to write to check that
- out.
-
- 5- Speaking of MacApp, this scheme can indeed be implemented an object field as
- shown earlier. And this does not mean that the restrictions discussed in 1-
- above don't apply any more. The scheme is just a bit safer. However I have no
- idea as to how an error handler (for example) could avoid poking inside the
- content of an object to unlock it, or more precisely, to restore the count to
- the value it had just before the handler was installed! In fact I have one,
- unusable: the lock method installs a handler, the unlock method calls
- success!!!
-
-
- Please comment!
-
- Jean-Denis Muys-Vasovic
- Developer Services - R&D Europe
-
-
-